/**
 * 
 */
package com.xingfume.article.dao.impl;

import java.lang.reflect.Field;
import java.util.Collection;

import org.springframework.stereotype.Repository;

import com.xingfume.article.Article;
import com.xingfume.article.dao.ArticleDao;
import com.xingfume.user.User;

/** 
 * @author kevin weizhikai.ai@gmail.com: 
 * @version 创建时间：2015年5月22日 下午2:11:03 
 * 项目名称：articles-manager-system
 * 项目名称：ArticleDaoImpl
 */
/**
 * @author kevin
 *
 */
@Repository
public class ArticleDaoImpl implements ArticleDao{

	/* (non-Javadoc)
	 * @see com.xingfume.article.dao.ArticleDao#insert(com.xingfume.article.Article)
	 */
	public boolean insert(Object article) 
	{
/*		JedisPool pool = JedisPoolInit.getJedisPool();
		Jedis jedis = pool.getResource();*/
		Field[] fields = article.getClass().getDeclaredFields();
		for(int i = 0, len = fields.length; i < fields.length; i++)
		{
			String varName = fields[i].getName();
			System.out.println(varName);
		}
/*		jedis.hset("article:001", "uuid", "001");
		String uuid = jedis.hget("article:001", "uuid");
		System.out.println(uuid + "///uuid");
		pool.returnResourceObject(jedis);
		pool.destroy();*/
		return false;
	}

	/* (non-Javadoc)
	 * @see com.xingfume.article.dao.ArticleDao#remove()
	 */
	public boolean remove() {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see com.xingfume.article.dao.ArticleDao#used()
	 */
	public boolean used() {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see com.xingfume.article.dao.ArticleDao#update()
	 */
	public boolean update() {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see com.xingfume.article.dao.ArticleDao#queryById()
	 */
	public Article queryById() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.xingfume.article.dao.ArticleDao#queryWhere()
	 */
	public Collection<Article> queryWhere() {
		// TODO Auto-generated method stub
		return null;
	}
	
	//转map
	/*private Map<String, String> getValueMap(Object obj) {  
		  
        Map<String, String> map = new HashMap<String, String>();  
        // System.out.println(obj.getClass());  
        // 获取f对象对应类中的所有属性域  
        Field[] fields = obj.getClass().getDeclaredFields();  
        for (int i = 0, len = fields.length; i < len; i++) {  
            String varName = fields[i].getName();  
            try {  
                // 获取原来的访问控制权限  
                boolean accessFlag = fields[i].isAccessible();  
                // 修改访问控制权限  
                fields[i].setAccessible(true);  
                // 获取在对象f中属性fields[i]对应的对象中的变量  
                Object o = fields[i].get(obj);  
                if (o != null)  
                    map.put(varName, o.toString());  
                // System.out.println("传入的对象中包含一个如下的变量：" + varName + " = " + o);  
                // 恢复访问控制权限  
                fields[i].setAccessible(accessFlag);  
            } catch (IllegalArgumentException ex) {  
                ex.printStackTrace();  
            } catch (IllegalAccessException ex) {  
                ex.printStackTrace();  
            }  
        }  
        return map;  
  
    }  */

	public static void main(String[] args) {
		Article article = new Article();
		article.setArticleId("aaa");
		User user = new User();
		user.setNickname("aaaa");
		ArticleDaoImpl artDao = new ArticleDaoImpl();
		artDao.insert(user);
	}
}
